import {request} from "umi";

/**
 * 分页返回所有权限
 * @param current
 * @param page_size
 */
export function getPermissions(current: number = 1, page_size: number = 20) {
  return request<ABIS.Pagination<ABIS.Permission>>(
    '/api/permissions/list',
    {
      params: {
        current,
        page_size
      }
    }
  )
}

/**
 * 获取所有权限组
 */
export function getPermissionGroup() {
  return request<ABIS.ResultList<ABIS.PermissionGroup>>(
    '/api/permissions/groups'
  )
}

export function getPermissionsByGroup(group: string, current?: number, page_size?: number) {
  return request<ABIS.Pagination<ABIS.Permission>>(
    '/api/permissions/permission-by-group',
    {
      params: {
        group,
        current,
        page_size
      }
    }
  )
}
